﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
namespace Mobile_terminal
{
    /// <summary>
    /// UpImage 的摘要说明
    /// </summary>
    public class UpImage : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //上传文件
            HttpPostedFile file = context.Request.Files["Images"];
            if (file == null) 
            {
                context.Response.Write("请选择上传文件");
            }
            else
            {
                //存储照片的路径
                string path = HttpContext.Current.Server.MapPath("~/UpImage/");
                if (!Directory.Exists(path)) 
                {
                    Directory.CreateDirectory(path);
                }
                string name = file.FileName;//获取文件名字
                file.SaveAs(path + name);
                context.Response.Write(name);

            }

            context.Response.Write("Hello World");
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}